#coding=utf-8
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
import os,datetime
from google.appengine.ext.webapp import template



timeScale = {1:4,2:7,3:12,4:20,5:30,6:60,7:90,8:150,9:270,10:480}

class Page(db.Model):
  author = db.UserProperty()
  pageName = db.StringProperty()
  createTime = db.DateTimeProperty(auto_now_add=True)
  nextTime = db.DateTimeProperty(auto_now_add=True)
  times = db.IntegerProperty()
  def updateNextTime(self):
      self.times = self.times+1;
      self.nextTime = datetime.timedelta(days=timeScale[self.times]) 
  
class Question(db.Model):
  PageId = db.IntegerProperty()
  question = db.StringProperty()
  answer = db.StringProperty()
  tag = db.StringProperty()
  wrongTimes = db.IntegerProperty()
  wrong = db.BooleanProperty()
  
class PageRecord(db.Model):
  PageId = db.IntegerProperty()
  times = db.IntegerProperty() 
  date = db.DateTimeProperty() 